/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2024-03-27
 * Time: 14:22
 */
public class Demo8 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread2=new Thread(()->{
            for (int i = 0; i <5 ; i++) {
                System.out.println("hello thread2");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("2      end");
        });
        Thread thread1=new Thread(()->{
            try {
                thread2.join(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            for (int i = 0; i < 5; i++) {
                System.out.println("hello thread1");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

            System.out.println("1  end");
        });

        thread1.start();
      //Thread.sleep(1000);
        thread2.start();
    }
}
